<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="../../../dep/jquery-1.11.1.js" type="text/javascript"></script>
    <script src="../../../dep/jquery.di.js" type="text/javascript"></script>
	<script>
		$(function () {
			$('#btnClickMe').click(function () {
				var str = '新加一个';
				var $txtContent = $('#txtContent');
				var text = $txtContent.val();
				var curIndex = $.getCursorPosition($txtContent[0]);
				var newText = text.slice(0, curIndex) + str + text.slice(curIndex, text.length);

				$txtContent.val(newText);
				//$txtContent.setCursorPosition((curIndex + str.length));
				$txtContent.diFocus((curIndex + str.length));
				//$txtContent.focus((curIndex + str.length));
			});
		});

	</script>
</head>
<body>
<textarea name="txtContent" id="txtContent" cols="30" rows="10"></textarea>
<input id="btnClickMe" type="button" value="猛戳我"/>
</body>
</html>